﻿@model ArivisTests.Models.TestRun
@using ArivisTests.Models;
@using ArivisTests.Views;

@{
    ViewBag.Title = "Edit";
}

@section Navigation{
    @Html.ActionLink("Test Runs", "Index")
    &rsaquo;
    @Html.DisplayFor(model => model.Name)
}

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Test Run</legend>

        @Html.HiddenFor(model => model.Id)

        <table class="editor-table">
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.Name)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.Name)
                    @Html.ValidationMessageFor(model => model.Name)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.Date)
                </td>
                <td class="editor-field">
                    @Html.TextBoxFor(model => model.Date, "{0:d}")
                    @Html.ValidationMessageFor(model => model.Date)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.Active)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.Active)
                    @Html.ValidationMessageFor(model => model.Active)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.DisplayNameFor(model => model.Progress)
                </td>
                <td class="editor-field">
                    @Html.DisplayFor(model => model.Progress)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.DisplayNameFor(model => model.Results)
                </td>
                <td class="editor-field">
                    @Html.DisplayFor(model => model.Results)
                </td>
            </tr>
        </table>

        <input type="submit" value="Save" />
    </fieldset>
}

@using (Html.BeginForm("RemoveTest", "TestRun")) {
    @Html.ValidationSummary(true)
<fieldset>
    <legend>Remove Test Cases</legend>
    @Html.HiddenFor(model => model.Id)

    <div style="max-height:400px; overflow-y:scroll;border:1px solid #ccc;">
        <table class="index-table">
            <tr>
                <th width="1%"></th>
                <th>Test Case</th>
                <th>Tester</th>
                <th>Result</th>
            </tr>
            @foreach (var testcase in Model.Tests.OrderBy(x => x.Name))
                {
                <tr>
                    <td><input type="checkbox" name="testcase" id="testcase_@testcase.Id" value="@testcase.Id" /></td>
                    <td><label for="testcase_@testcase.Id">@testcase.Name</label></td>
                    <td>@if (testcase.User != null) { @testcase.User.UserName }</td>
                    <td>@if (testcase.Result != null) { @testcase.Result.Name }</td>
                </tr>
                }
        </table>
    </div>
    <br />
    <input type="submit" value="Delete selected test cases" />
</fieldset>
}

<div>
    @Html.ActionLink("View", "Details", new { id=Model.Id }) |
    @Html.ActionLink("Delete", "Delete", new { id=Model.Id }) |
    @Html.ActionLink("Assign Tester Manual", "Manual", "AssignTest", new { id = Model.Id }, null) |
    @Html.ActionLink("Assign Tester Automatic", "Automatic", "AssignTest", new { id = Model.Id }, null)
</div>
